#include "./leetcode.h"
/*
https://leetcode.cn/problems/find-words-that-can-be-formed-by-characters
*/
int countCharacters(char** words, int wordsSize, char* chars)
{
    int res = 0;

    for (int i = 0; i < wordsSize; i++)
    {

        int dic[26] = { 0 };
        char* c = chars;
        while (*c != '\0')
        {
            dic[(*c) - 97]++;
            c++;
        } // 字典完成

        char* word = words[i];
        int reset = res;
        int flag = 1;
        while (*word != '\0')
        {
            if (!dic[(*word) - 97]--)
            {
                flag = 0;
                break;
            }
            else
            {
                res++;
            }
            word++;
        }

        if (!flag)
        {
            res = reset;
        }
    }

    return res;

}


int main()
{
    char* c = "helloworld";
    for (int i = 0; i < 10; i++)
    {
        printf("%d ", *c);
    }
    return 0;
}